/**
 * Created by ASUS on 2018/1/5.
 */
function initMessageVueObj(){
//    数据默认通过ajax请求
    var messageVueObj = new Vue({
        el:"#messageBox",
        data:{
            isEdit:false,
            messageMainList:[
                {
                    name:"通知",
                    img:"",
                    lastMessage:{
                        content:"您的体检信息已确认,请您按时前往体检",
                        createTime:"2017-08-12 14:22"
                    },
                    unCheckedMessageCount:2,
                    isSelect:false
                },
                {
                    name:"物流",
                    img:"",
                    lastMessage:{
                        content:"您购买的体检卡产品已发货",
                        createTime:"2017-08-12 14:22"
                    },
                    unCheckedMessageCount:0,
                    isSelect:false
                }
            ]
        },
        methods:{
            select:function(item){
                if(item.isSelect){
                    var index = this.messageMainList.indexOf(item);
                    this.messageMainList[index].isSelect = false;
                    messageBoxFooter.isSelect = false;
                    var flag = true;
                    this.messageMainList.map(function(ele,index){
                        if(ele.isSelect == true){
                            flag = false;
                        }
                    });
                    if(flag){
                        messageBoxFooter.hasSelectItem = false;
                    }


                }else{
                    var index = this.messageMainList.indexOf(item);
                    this.messageMainList[index].isSelect = true;
                    messageBoxFooter.hasSelectItem = true;
                    var flag = true;
                    this.messageMainList.map(function(ele,index){
                        if(ele.isSelect == false){
                            flag = false;
                        }
                    });
                    if(flag){
                        messageBoxFooter.isSelect = true;
                    }
                }
            }
        }
    });

    var messageControl = new Vue({
        el:"#messageControl",
        data:{
            isEdit:false
        },
        methods:{
            edit:function(){
                if(!this.isEdit){
                    this.isEdit = !this.isEdit;
                    messageVueObj.isEdit = this.isEdit;
                    messageBoxFooter.isEdit = this.isEdit;
                }else{
                    this.isEdit = !this.isEdit;
                    messageVueObj.isEdit = this.isEdit;
                    messageBoxFooter.isEdit = this.isEdit;
                }
            }
        }
    });
    var messageBoxFooter = new Vue({
        el:"#messageBoxFooter",
        data:{
            isEdit:messageControl.isEdit,
            isSelect:false,
            hasSelectItem:false
        },
        methods:{
            selectAll:function(){
                this.isSelect = !this.isSelect;
                var _this = this;
                messageVueObj.messageMainList.map(function(ele,index){
                    messageVueObj.messageMainList[index].isSelect = _this.isSelect;
                });
                this.hasSelectItem = this.isSelect;
            },
            setToChecked:function(){

            }
        }
    })


}